package com.cdl.collectiontest;

import java.util.ArrayList;
import java.util.List;

public class ListDemo  {

    public static void main(String[] args) {
        List<String> list = new ArrayList<>();  //经典的代码

        list.add("aa");
        list.add("bb");
        list.add("cc");
        list.add("dd");

        System.out.println("list = " + list);

        list.add(1,"ee");
        System.out.println("list = " + list);

        //通过元素获取下标
        System.out.println(list.indexOf("bb"));

        System.out.println(list.get(2));
        list.set(2,"ff");

        System.out.println(list);

        for (int i = 0; i < list.size(); i++) {
            System.out.println(list.get(i));
        }













    }



}
